package com.ang.propagation.tt;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

import java.util.stream.IntStream;

@Component
public class TTService1 {
    @Autowired
    private TTService2 tService2;

    @Autowired
    private JdbcTemplate jdbcTemplate;

    @Transactional
    public void trans() {
        IntStream.range(1, 6).forEach(i -> {
            if (i < 3) {
                tService2.insert1(i);
            } else if (i > 3) {
                tService2.insert2(i);
            } else {
                //抛异常
            }
        });
    }
}
